package org.summer.gateway.controller;

import lombok.RequiredArgsConstructor;
import lombok.extern.log4j.Log4j2;
import org.summer.common.http.Result;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.summer.gateway.dto.MysqlReplicaStatus;
import org.summer.gateway.service.MainService;
import reactor.core.publisher.Mono;

/**
 * 网关唯一主要接口
 * <p>实现网关主要系统级别功能</p>
 * @author gvp9132
 * @date 2024/9/23
 * @since 1.0
 */
@Log4j2
@RestController
@RequestMapping("/main")
@RequiredArgsConstructor
public class MainController {
    private final MainService mainService;

    /**
     * 获取mysql主从复制状态
     */
    @GetMapping("/mysql")
    public Mono<Result<MysqlReplicaStatus>> queryMysqlStatus(){
        return this.mainService.findMysqlReplicaStatus();
    }

    /**
     * 测试无权限接口
     */
    @GetMapping("/no-auth")
    public Mono<String> testNoAuth(){
        log.debug("测试无权限接口");
        return Mono.just("no auth success");
    }

    /**
     * 测试网关连接
     */
    @GetMapping("/test")
    public Mono<String> testConnect(){
       log.debug("测试网关连接");
       return Mono.just("connect success");
    }

    /**
     * 获取mysql状态信息
     */
    @GetMapping("/mysql/status")
    public Mono<Object> queryMySQLStatus(){
        log.debug("获取mysql状态信息");
        return Mono.just("mysql status");
    }
}
